using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NTTHAO.Web.BL.CommonPage;
using NTTHAO.CommonWeb;
using System.Collections.Generic;

public partial class Sites_Vigor_Webparts_Pages_DefaultContent1 : NTTHAO.CommonWeb.CommonUserControl
{
    public CommonPageGroup _Group = null;
    public CommonMenu _RootMenu = null;
    public CommonMenu _CurrentMenu = null;
    public CommonPageContent _Content = null;
    public List<CommonMenu> _MenuPath = new List<CommonMenu>();

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            _Group = this.GetCurrentPageGroup();
            _RootMenu = this.GetRootMenu();
            _CurrentMenu = this.GetCurrentMenu();
            _Content = this.GetCurrentContent();

            CommonMenu menu = _CurrentMenu;
            while (menu != null)
            {
                _MenuPath.Insert(0, menu);
                menu = CommonMenu.GetCommonMenu(menu.ParentID);
            }

            if (_Content == null)
            {
                if (_CurrentMenu != null)
                {
                    _Content = _CurrentMenu.GetDefaultContent(_CurrentMenu.ID);

                    if (_Content == null)
                    {
                        DataTable tb = CommonPageContent.GetTopByInsertTime(_CurrentMenu.ID, 1, false, 0, 1);
                        if (tb != null && tb.Rows.Count > 0)
                        {
                            _Content = new CommonPageContent((int)tb.Rows[0][CommonPageContent.ID__COLUMN_NAME]);
                        }
                    }
                }
            }
        }
        catch { }

        if (_Content != null)
        {
            this.Session["PAGE_TITLE"] = _Content.Header.Replace(Environment.NewLine, "").Replace("\"", "'");
            this.Session["PAGE_DESCRIPTION"] = NTTHAO.CommonWeb.WebGlobal.GetPlainText(_Content.Description).Replace("\"", "'").Replace(Environment.NewLine, "");
        }
    }
}
